<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>Send file</title>

 </head>
 <body><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="function.http-send-data.html">http_send_data</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="function.http-send-last-modified.html">http_send_last_modified</a></div>
 <div class="up"><a href="ref.http.html">HTTP 函数</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div><hr /><div id="function.http-send-file" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">http_send_file</h1>
  <p class="verinfo">(PECL pecl_http &gt;= 0.1.0)</p><p class="refpurpose"><span class="refname">http_send_file</span> &mdash; <span class="dc-title">Send file</span></p>

 </div>
 <div class="refsect1 description" id="refsect1-function.http-send-file-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="type">bool</span> <span class="methodname"><strong>http_send_file</strong></span>
    ( <span class="methodparam"><span class="type">string</span> <code class="parameter">$file</code></span>
   )</div>

  <p class="para rdfs-comment">
   Sends a file with support for (multiple) range requests.
  </p>
  <p class="para">
   This functions behaviour and further action is dependent on the following
   <a href="http.configuration.html" class="link">INI 设置</a>s:
   <a href="" class="link">http.send.not_found_404</a>
    和  <a href="" class="link">http.log.not_found</a>.
  </p>
  <p class="para">
   If the <a href="http.configuration.html" class="link">INI 设置</a> <a href="" class="link">http.send.not_found_404</a>
   is enabled and the <a href="http.configuration.html" class="link">INI 设置</a> <a href="" class="link">http.log.not_found</a>
   points to a writable file, a log message is written when the <em><code class="parameter">file</code></em> was not found.
  </p>
 </div>

 <div class="refsect1 parameters" id="refsect1-function.http-send-file-parameters">
  <h3 class="title">参数</h3>
  <p class="para">
   <dl>

    
     <dt>
<em><code class="parameter">file</code></em></dt>

     <dd>

      <p class="para">
       the file to send
      </p>
     </dd>

    
   </dl>

  </p>
 </div>

 <div class="refsect1 returnvalues" id="refsect1-function.http-send-file-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
   成功时返回 <strong><code>TRUE</code></strong>， 或者在失败时返回 <strong><code>FALSE</code></strong>。
  </p>
 </div>


 


 


 <div class="refsect1 examples" id="refsect1-function.http-send-file-examples">
  <h3 class="title">范例</h3>
  <p class="para">
   <div class="example" id="example-4281">
    <p><strong>Example #1 A <span class="function"><strong>http_send_file()</strong></span> example</strong></p>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br />http_send_content_disposition</span><span style="color: #007700">(</span><span style="color: #DD0000">"document.pdf"</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">true</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">http_send_content_type</span><span style="color: #007700">(</span><span style="color: #DD0000">"application/pdf"</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">http_throttle</span><span style="color: #007700">(</span><span style="color: #0000BB">0.1</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">2048</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">http_send_file</span><span style="color: #007700">(</span><span style="color: #DD0000">"../report.pdf"</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
    </div>

    <div class="example-contents"><p>以上例程会输出：</p></div>
    <div class="example-contents screen">
<div class="cdata"><pre>
HTTP/1.1 206 Partial Content
X-Powered-By: PHP/5.2.2
Accept-Ranges: bytes
Content-Length: 12345
Content-Range: bytes 0-12344
Content-Type: application/pdf
Content-Disposition: inline; filename=&quot;document.pdf&quot;

%PDF...
</pre></div>
    </div>
   </div>
  </p>
 </div>



 <div class="refsect1 seealso" id="refsect1-function.http-send-file-seealso">
  <h3 class="title">参见</h3>
  <p class="para">
   <ul class="simplelist">
    <li class="member"><span class="function"><a href="function.http-send-data.html" class="function" rel="rdfs-seeAlso">http_send_data()</a> - Send arbitrary data</span></li>
    <li class="member"><span class="function"><a href="function.http-send-stream.html" class="function" rel="rdfs-seeAlso">http_send_stream()</a> - Send stream</span></li>
    <li class="member"><span class="function"><a href="function.http-throttle.html" class="function" rel="rdfs-seeAlso">http_throttle()</a> - HTTP throttling</span></li>
    <li class="member"><span class="function"><a href="function.http-send-content-type.html" class="function" rel="rdfs-seeAlso">http_send_content_type()</a> - Send Content-Type</span></li>
    <li class="member"><span class="function"><a href="function.http-send-content-disposition.html" class="function" rel="rdfs-seeAlso">http_send_content_disposition()</a> - Send Content-Disposition</span></li>
    <li class="member">如使用 PHP 5.1.0 及以后版本中为
<a href="class.httpresponse.html" class="link">
<a href="class.httpresponse.html" class="classname">HttpResponse</a></a> 类。</li>
   </ul>
  </p>
 </div>



</div><hr /><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="function.http-send-data.html">http_send_data</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="function.http-send-last-modified.html">http_send_last_modified</a></div>
 <div class="up"><a href="ref.http.html">HTTP 函数</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div></body></html>
